package com.itcg.springboot01change.pojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

//封装统一响应结果的
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Result {
    //响应结果的状态码, 比如: 1表示成功, 0表示失败
    private Integer status;

    //响应结果状态码的描述信息
    private String msg;

    //真正的响应的结果数据
    private Object data;

    //成功的静态方法(有数据)
    public static Result success(Object data) {
        return new Result(1,"success",data);
    }

    //成功的静态方法(没有数据)
    public static Result success() {
        return new Result(1,"success",null);
    }

    //成功的静态方法(没有数据)
    public static Result success(String msg) {
        return new Result(1,msg,null);
    }
    //失败的静态方法(没有数据)
    public static Result error() {
        return new Result(0,"error",null);
    }

    public static Result error(String msg) {
        return new Result(0,msg,null);
    }
}
